home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / swapscrn.c < prev    next >
C/C++ Source or Header  |  1988-12-07  |  2KB  |  66 lines

  1. /* swapscrn.c -- 9/5/88, d.c.oshel
  2.    */
  3.  
  4. #include "vidinit.h"
  5.  
  6.  
  7. /*=================*/
  8. /* screen handlers */
  9. /*=================*/
  10.  
  11. void setscreen( int n ) /* set activescreen = 1 or 2, screen 1 is visible */
  12. {
  13.      if (!Initialized) vid_init(0);
  14.  
  15.      /* this is kinduva donothing routine just now...
  16.         might get around to enhancing or expanding it later
  17.         */
  18.  
  19.      switch (n)
  20.      {
  21.          case 2:  { activescreen = ptrseg( hidescreen ); 
  22.                     activeoffset = ptrofs( hidescreen );
  23.                   break; }
  24.          default:
  25.          case 1:  { activescreen = video.SegAddr;
  26.                     activeoffset = 0;
  27.                   break; }
  28.      }
  29. }
  30.  
  31.  
  32. void swapscreen( int n ) /* swap hidden screen n with visible screen 1 */
  33. {                            /* for now, n can only be 2, is ignored  */   
  34.      char far *p;
  35.      char far *q;
  36.      union REGS x;
  37.  
  38.      int i, c;
  39.  
  40.      if (!Initialized) vid_init(0);
  41.  
  42.      /* at first, the hidden screen contains a copy of whatever
  43.         screen was active when vid_init() was called at startup
  44.  
  45.         NOTE: savescreen() and restorescreen() use the low-level MSJ
  46.               functions, so swapscreen() now eliminates snow!
  47.         */
  48.         
  49.      p = savescreen( &x );  /* copy visible screen into a buffer */
  50.      q = hidescreen;        /* ptr to invisible hidden screen */
  51.  
  52.      for ( i = 0; i < SCRLIM; i++ )  /* swap the two buffers */
  53.      {
  54.         c = *( q + i );
  55.             *( q + i ) = *( p + i );
  56.                          *( p + i ) = c;
  57.      }
  58.  
  59.      restorescreen( p,&x ); /* copy invisible buffer back onto screen */
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.